package com.example.dialog.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;

import com.example.dialog.Activity.CreateActivity;
import com.example.dialog.Activity.MessageActivity;
import com.example.dialog.Activity.ProfileActivity;
import com.example.dialog.Adapter.HomeViewPagerAdapter;
import com.example.dialog.R;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

public class HomeActivity extends BaseActivity {
    private ViewPager2 viewPager;
    private TabLayout tabLayout;
    private AppBarLayout appBarLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        viewPager = findViewById(R.id.viewPager);
        tabLayout = findViewById(R.id.tabLayout);
        appBarLayout = findViewById(R.id.appBarLayout);

        // 设置ViewPager
        viewPager.setAdapter(new HomeViewPagerAdapter(this));

        // 设置TabLayout
        new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
            tab.setText(position == 0 ? "关注" : "发现");
        }).attach();

        // 设置默认显示"发现"页面
        viewPager.setCurrentItem(1, false);

        setupBottomNavigation();
        doSearch();
    }

    private void doSearch(){
        findViewById(R.id.searchIcon).setOnClickListener(v -> {
            startActivity(new Intent(this,SearchActivity.class));
        });
    }


}